package org.qqcui.designpattern.patterns.mediator;

/**
 * 中介者模式客户端
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/6 17:30
 **/
public class Client {

    public static void main(String[] args) {
        // 创建一个中介者
        Mediator mediator = new ConcreteMediator();
        // 创建Alarm并加入到中介者对象中的Map中
        Alarm alarm = new Alarm(mediator, "alarm");
        CoffeeMachine coffeeMachine = new CoffeeMachine(mediator, "coffeeMachine");
        Curtain curtain = new Curtain(mediator, "curtain");
        TV tv = new TV(mediator, "tv");

        // 闹钟发出消息
        alarm.sendMessage(0);
        coffeeMachine.finishCoffee();
        alarm.sendMessage(1);
    }
}
